﻿
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using UtilityLibrary.WinControls;
namespace CKNetFrameWork
{
    public partial class Frm_MainToolWindowNew : DockContent
    {

        private void InitializeOutlookbar()
        {
            this.treeViewTask.Nodes.Clear();

            TreeNode nodeRoot = new TreeNode();
            nodeRoot.Text = "百业信息管理系统";
            nodeRoot.Tag = -1;
            this.treeViewTask.Nodes.Add(nodeRoot);


            foreach (string strModule in Frm_Main.m_dicFormText2FormTypeName.Keys)
            {
                TreeNode node = new TreeNode();
                node.Text = strModule;

                node.Tag = 0;
                node.ImageIndex = 0;
                nodeRoot.Nodes.Add(node);
                foreach (string strItem in Frm_Main.m_dicFormText2FormTypeName[strModule].Keys)
                {
                    TreeNode nodeChild = new TreeNode();
                    nodeChild.Text = strItem;

                    nodeChild.Tag = 1;
                    nodeChild.ImageIndex = 1;
                    node.Nodes.Add(nodeChild);

                }

            }

            this.treeViewTask.SelectedNode = this.treeViewTask.TopNode;
            nodeRoot.Expand();

            //foreach (string strModule in Frm_Main.m_dicFormText2FormTypeName.Keys)
            //{
            //    OutlookBarBand outlookShortcutsBand = new OutlookBarBand(strModule);
            //    outlookShortcutsBand.SmallImageList = this.imageList;
            //    outlookShortcutsBand.LargeImageList = this.imageList;
            //    int nImageIndex = 0;
            //    foreach (string strItem in Frm_Main.m_dicFormText2FormTypeName[strModule].Keys)
            //    {
            //        outlookShortcutsBand.Items.Add(new OutlookBarItem(strItem, nImageIndex++));
            //        outlookShortcutsBand.Background = SystemColors.AppWorkspace;
            //        outlookShortcutsBand.TextColor = Color.White;

            //    }

            //    outlookBar1.Bands.Add(outlookShortcutsBand);
            //}

            //outlookBar1.Dock = DockStyle.Fill;
            //outlookBar1.SetCurrentBand(0);
            ////OutlookBarBand bb = outlookBar1.Bands[1];
            //// bb.Items[0]
            //outlookBar1.ItemClicked += new OutlookBarItemClickedHandler(OnOutlookBarItemClicked);
            //outlookBar1.ItemDropped += new OutlookBarItemDroppedHandler(OnOutlookBarItemDropped);
            ////outlookBar1.BandClicked += new OutlookBarBandClickedHandler(OnOutlookBarBandClicked);
            ////outlookBar1.FlatArrowButtons = true;
            //this.panel1.Controls.AddRange(new Control[] { outlookBar1 });
        }
        
         private void OnOutlookBarItemClicked(OutlookBarBand band, OutlookBarItem item)
        {
            Frm_Main.GetMainForm().ShowContent(item.Text);
           
        }

         private void OnOutlookBarItemDropped(OutlookBarBand band, OutlookBarItem item)
         {
             //            string message = "Item : " + item.Text + " was dropped";
             //            MessageBox.Show(message);            
         }
         public Frm_MainToolWindowNew()
        {
            
            InitializeComponent();
            InitializeOutlookbar();
        }

         private void Frm_MainToolWindow_Load(object sender, EventArgs e)
         {

         }

  

         private void treeViewTask_MouseDoubleClick(object sender, MouseEventArgs e)
         {
             Point pos = new Point(e.X, e.Y);
             TreeNode nodeClick = this.treeViewTask.GetNodeAt(pos);
             if (nodeClick.Text == "百业信息管理系统")
             {


                 return;
             }
             if (nodeClick != null && e.Button == MouseButtons.Left)
             {
                 int nTag = (int)nodeClick.Tag;
                 if (nTag == 0)
                 {
                     return;
                 }
                 this.treeViewTask.SelectedNode = nodeClick;

                 //LoadInfoByNode();

             }

             //ShowContent((string)this.treeViewTask.SelectedNode.Parent.Text + "\\" + (string)this.treeViewTask.SelectedNode.Text);
             Frm_Main.GetMainForm().ShowContent(this.treeViewTask.SelectedNode.Text);
         }
    }
}

